package com.honghu.cloud.utils;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.honghu.cloud.feign.SysConfigFeignClient;

/**
 * 集群下同步文件
 * @author Administrator
 *
 */
@Component
public class ClusterSyncTools {

	@Autowired
	private SysConfigFeignClient sysConfigFeignClient;
	
	private static ClusterSyncTools clusterSyncTools;
	 
	@PostConstruct 
	public void init() {
		clusterSyncTools = this;
		clusterSyncTools.sysConfigFeignClient = this.sysConfigFeignClient;
	}
	
	
	
	public static boolean isUnix() {
		String osname = System.getProperties().getProperty("os.name");
		String windows = "windows";
		String linux = "linux";
		if (osname != null && osname.toLowerCase().contains(windows)) {
			return false;
		} else if (osname != null && osname.toLowerCase().contains(linux)) {
			return true;
		}
		return true;
	}

	public static boolean isWins() {
		String osname = System.getProperties().getProperty("os.name");
		String windows = "windows";
		String linux = "linux";
		if (osname != null && osname.toLowerCase().contains(windows)) {
			return true;
		} else if (osname != null && osname.toLowerCase().contains(linux)) {
			return false;
		}
		return true;
	}
	
	/**
	 * 获取项目资源路径
	 * @return
	 */
	public static String getClusterRoot() {
		
		return clusterSyncTools.sysConfigFeignClient.getSysConfig().getLucenePath();
	}
	
	/**
	 * 获取项目资源路径
	 * @return
	 */
	public static String getCDN() {
		
		return clusterSyncTools.sysConfigFeignClient.getSysConfig().getImageWebServer();
	}

}
